class CreateInventoryDetails < ActiveRecord::Migration
  def self.up
    create_table :inventory_details do |t|
      t.integer :inventory_id             ,:null => false       #这是详表所对应的主表ID
      t.integer :product_id               ,:null => false       #这是详表所对应的产品ID
      t.integer :quantity       ,:default => 0     #实盘数量
      t.integer :gl_quantity    ,:default => 0     #损益数量      gains and loss quantity
      t.decimal :unit_price     ,:null => false , :precision => 8, :scale => 2  ,:default => 0     #单价
      t.decimal :amount  , :precision => 10, :scale => 2  ,:default => 0     #金额，这个选项的业务内容还没有完全了解清楚
      t.string  :description                    #写一些备注之类的信息
      t.integer :is_locked     , :limit => 1  ,:default => 0   #锁定 1为True 0为False
      t.integer :lock_version  , :default => 0  #乐观锁
      t.timestamps
    end
  end

  def self.down
    drop_table :inventory_details
  end
end
